//
//  ChannelListBtn.m
//  ShrimpCrowdordering
//
//  Created by 郑洲 on 2018/7/25.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "ChannelListBtn.h"

@interface ChannelListBtn()

@property (nonatomic, strong) UIImageView *bgView;
@property (nonatomic, strong) UILabel *brandLabel;
@property (nonatomic, strong) UILabel *noteLabel;

@end

@implementation ChannelListBtn

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = ScreenX375(8);
        self.clipsToBounds = YES;
        self.userInteractionEnabled = YES;
        
        self.bgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        self.bgView.userInteractionEnabled = YES;
        self.bgView.clipsToBounds = YES;
        self.bgView.contentMode = UIViewContentModeScaleAspectFill;
        [self addSubview:self.bgView];
        
        self.brandLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, ScreenX375(40), frame.size.width, ScreenX375(14))];
        self.brandLabel.textColor = [UIColor whiteColor];
        self.brandLabel.textAlignment = NSTextAlignmentCenter;
        self.brandLabel.font = Kfont(9);
        [self addSubview:self.brandLabel];
        
        self.noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, ScreenX375(58), frame.size.width, ScreenX375(13))];
        self.noteLabel.textColor = [UIColor whiteColor];
        self.noteLabel.textAlignment = NSTextAlignmentCenter;
        self.noteLabel.font = Kfont(11);
        [self addSubview:self.noteLabel];
        
        self.button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        [self addSubview:self.button];
    }
    return self;
}

- (void)initWithImageName:(NSString *)imageName andTitle:(NSString *)title andNote:(NSString *)note {
    [self.bgView sd_setImageWithURL:[NSURL URLWithString:imageName] placeholderImage:nil options:SDWebImageRetryFailed];
    self.brandLabel.text = title;
    self.noteLabel.text = note;
}

@end
